set ( PN neuma )
project( ${PN} )

set ( EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/neuma/bin )

include_directories (
  ${CMAKE_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
  )

set ( ${PN}_HDRS
  BlockNeuma.h
  Interface_SourceParser.h
  SettingsHandler.h
  SNPair.h
  utils.h
  )

set ( ${PN}_SRCS
  BlockNeuma.cpp
  DisplayWidget.cpp
  main.cpp
  MainWindow.cpp
  MainWindow_drawing.cpp
  MainWindow_files.cpp
  SettingsDialog.cpp
  SettingsHandler.cpp
  utils.cpp
  )

set ( ${PN}_UIS
  ../forms/MainWindow.ui
  ../forms/SettingsDialog.ui
  )

set ( ${PN}_RSCS
  ../res/resources.qrc
  )

set ( ${PN}_MOCS
  DisplayWidget.h
  MainWindow.h
  SettingsDialog.h
  )

QT4_WRAP_CPP ( MOCS ${${PN}_MOCS} )
QT4_ADD_RESOURCES ( RSCS ${${PN}_RSCS} )
QT4_WRAP_UI ( UIS ${${PN}_UIS} )

# if windows
if ( WIN32 )
  # and MSVC colpiler
#  if ( MSVC )
    find_program ( WINDRES
      NAMES windres.exe
      PATHS ${PATH}
      NO_DEFAULT_PATH
      )

    add_custom_command ( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/neuma.rc.o
      COMMAND windres.exe
      -I{CMAKE_HOME_DIRECTORY}/res/
      -i${CMAKE_HOME_DIRECTORY}/res/neuma.rc
      -o ${CMAKE_CURRENT_BINARY_DIR}/neuma.rc.o
      )

    set ( ${PN}_SRCS ${${PN}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/neuma.rc.o )
#  endif ( MSVC ) 
  if ( CMAKE_BUILD_TYPE STREQUAL Release )
    set( CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-mwindows" )
  endif ()
endif ( WIN32 )

add_executable(${PN} ${${PN}_SRCS} ${UIS} ${RSCS} ${TRS} ${MOCS})
target_link_libraries(${PN}  ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTSVG_LIBRARY})

if(CMAKE_SYSTEM_NAME STREQUAL Linux)
  set(NEUMA_LIBS_DIR lib/neuma)
  install(TARGETS ${PN} DESTINATION bin COMPONENT ${PN})
endif()
